﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

// obtained from build_windows\db.h and dbinc\db.in
namespace BerkeleyDbWrapper
{
	enum LibConstants
	{
		DB_AGGRESSIVE = 0x00000001,
		DB_ARCH_ABS = 0x00000001,
		DB_ARCH_DATA = 0x00000002,
		DB_ARCH_LOG = 0x00000004,
		DB_ARCH_REMOVE = 0x00000008,
		DB_AUTO_COMMIT = 0x00000100,
		DB_CDB_ALLDB = 0x00000004,
		DB_CHKSUM = 0x00000004,
		DB_CKP_INTERNAL = 0x00000002,
		DB_CREATE = 0x00000001,
		DB_CXX_NO_EXCEPTIONS = 0x00000002,
		DB_DIRECT = 0x00000002,
		DB_DIRECT_DB = 0x00000040,
		DB_DSYNC_DB = 0x00000080,
		DB_DUP = 0x00000008,
		DB_DUPSORT = 0x00000002,
		DB_DURABLE_UNKNOWN = 0x00000020,
		DB_ENCRYPT = 0x00000001,
		DB_ENCRYPT_AES = 0x00000001,
		DB_EXCL = 0x00000400,
		DB_EXTENT = 0x00000004,
		DB_FAST_STAT = 0x00000001,
		DB_FCNTL_LOCKING = 0x00001000,
		DB_FLUSH = 0x00000001,
		DB_FORCE = 0x00000001,
		DB_FOREIGN_ABORT = 0x00000001,
		DB_FOREIGN_CASCADE = 0x00000002,
		DB_FOREIGN_NULLIFY = 0x00000004,
		DB_FREELIST_ONLY = 0x00000001,
		DB_FREE_SPACE = 0x00000002,
		DB_IGNORE_LEASE = 0x00001000,
		DB_IMMUTABLE_KEY = 0x00000002,
		DB_INIT_CDB = 0x00000020,
		DB_INIT_LOCK = 0x00000040,
		DB_INIT_LOG = 0x00000080,
		DB_INIT_MPOOL = 0x00000100,
		DB_INIT_REP = 0x00000200,
		DB_INIT_TXN = 0x00000400,
		DB_INORDER = 0x00000010,
		DB_JOIN_NOSORT = 0x00000001,
		DB_LOCKDOWN = 0x00000800,
		DB_LOCK_NOWAIT = 0x00000001,
		DB_LOCK_RECORD = 0x00000002,
		DB_LOCK_SET_TIMEOUT = 0x00000004,
		DB_LOCK_SWITCH = 0x00000008,
		DB_LOCK_UPGRADE = 0x00000010,
		DB_LOG_AUTO_REMOVE = 0x00000004,
		DB_LOG_CHKPNT = 0x00000002,
		DB_LOG_COMMIT = 0x00000004,
		DB_LOG_DIRECT = 0x00000001,
		DB_LOG_DSYNC = 0x00000002,
		DB_LOG_IN_MEMORY = 0x00000008,
		DB_LOG_NOCOPY = 0x00000008,
		DB_LOG_NOT_DURABLE = 0x00000010,
		DB_LOG_WRNOSYNC = 0x00000020,
		DB_LOG_ZERO = 0x00000010,
		DB_MPOOL_CREATE = 0x00000001,
		DB_MPOOL_DIRTY = 0x00000002,
		DB_MPOOL_DISCARD = 0x00000001,
		DB_MPOOL_EDIT = 0x00000004,
		DB_MPOOL_FREE = 0x00000008,
		DB_MPOOL_LAST = 0x00000010,
		DB_MPOOL_NEW = 0x00000020,
		DB_MPOOL_NOFILE = 0x00000001,
		DB_MPOOL_NOLOCK = 0x00000002,
		DB_MPOOL_UNLINK = 0x00000002,
		DB_MULTIPLE = 0x00002000,
		DB_MULTIPLE_KEY = 0x00000100,
		DB_MULTIVERSION = 0x00000008,
		DB_MUTEX_ALLOCATED = 0x00000001,
		DB_MUTEX_LOCKED = 0x00000002,
		DB_MUTEX_LOGICAL_LOCK = 0x00000004,
		DB_MUTEX_PROCESS_ONLY = 0x00000008,
		DB_MUTEX_SELF_BLOCK = 0x00000010,
		DB_NOLOCKING = 0x00000200,
		DB_NOMMAP = 0x00000010,
		DB_NOORDERCHK = 0x00000002,
		DB_NOPANIC = 0x00000400,
		DB_NO_AUTO_COMMIT = 0x00002000,
		DB_ODDFILESIZE = 0x00000040,
		DB_ORDERCHKONLY = 0x00000004,
		DB_OVERWRITE = 0x00001000,
		DB_PANIC_ENVIRONMENT = 0x00002000,
		DB_PRINTABLE = 0x00000008,
		DB_PRIVATE = 0x00001000,
		DB_PR_PAGE = 0x00000010,
		DB_PR_RECOVERYTEST = 0x00000020,
		DB_RDONLY = 0x00000080,
		DB_RDWRMASTER = 0x00004000,
		DB_READ_COMMITTED = 0x00000400,
		DB_READ_UNCOMMITTED = 0x00000200,
		DB_RECNUM = 0x00000020,
		DB_RECOVER = 0x00000010,
		DB_RECOVER_FATAL = 0x00002000,
		DB_REGION_INIT = 0x00004000,
		DB_REGISTER = 0x00004000,
		DB_RENUMBER = 0x00000040,
		DB_REPMGR_CONF_2SITE_STRICT = 0x00000001,
		DB_REPMGR_PEER = 0x00000001,
		DB_REP_ANYWHERE = 0x00000001,
		DB_REP_CLIENT = 0x00000001,
		DB_REP_CONF_BULK = 0x00000002,
		DB_REP_CONF_DELAYCLIENT = 0x00000004,
		DB_REP_CONF_LEASE = 0x00000008,
		DB_REP_CONF_NOAUTOINIT = 0x00000010,
		DB_REP_CONF_NOWAIT = 0x00000020,
		DB_REP_ELECTION = 0x00000004,
		DB_REP_MASTER = 0x00000002,
		DB_REP_NOBUFFER = 0x00000002,
		DB_REP_PERMANENT = 0x00000004,
		DB_REP_REREQUEST = 0x00000008,
		DB_REVSPLITOFF = 0x00000080,
		DB_RMW = 0x00000800,
		DB_RPCCLIENT = 0x00000001,
		DB_SALVAGE = 0x00000040,
		DB_SA_SKIPFIRSTKEY = 0x00010000,
		DB_SEQ_DEC = 0x00000001,
		DB_SEQ_INC = 0x00000002,
		DB_SEQ_RANGE_SET = 0x00000004,
		DB_SEQ_WRAP = 0x00000008,
		DB_SEQ_WRAPPED = 0x00000010,
		DB_SET_LOCK_TIMEOUT = 0x00000002,
		DB_SET_TXN_NOW = 0x00000004,
		DB_SET_TXN_TIMEOUT = 0x00000001,
		DB_SNAPSHOT = 0x00000100,
		DB_STAT_ALL = 0x00000002,
		DB_STAT_CLEAR = 0x00000001,
		DB_STAT_LOCK_CONF = 0x00000004,
		DB_STAT_LOCK_LOCKERS = 0x00000008,
		DB_STAT_LOCK_OBJECTS = 0x00000010,
		DB_STAT_LOCK_PARAMS = 0x00000020,
		DB_STAT_MEMP_HASH = 0x00000004,
		DB_STAT_MEMP_NOERROR = 0x00000008,
		DB_STAT_SUBSYSTEM = 0x00000004,
		DB_ST_DUPOK = 0x00000100,
		DB_ST_DUPSET = 0x00000200,
		DB_ST_DUPSORT = 0x00000400,
		DB_ST_IS_RECNO = 0x00000800,
		DB_ST_OVFL_LEAF = 0x00001000,
		DB_ST_RECNUM = 0x00002000,
		DB_ST_RELEN = 0x00004000,
		DB_ST_TOPLEVEL = 0x00008000,
		DB_SYSTEM_MEM = 0x00008000,
		DB_THREAD = 0x00000004,
		DB_TIME_NOTGRANTED = 0x00008000,
		DB_TRUNCATE = 0x00008000,
		DB_TXN_NOSYNC = 0x00000001,
		DB_TXN_NOT_DURABLE = 0x00000200,
		DB_TXN_NOWAIT = 0x00000002,
		DB_TXN_SNAPSHOT = 0x00000800,
		DB_TXN_SYNC = 0x00000004,
		DB_TXN_WAIT = 0x00000008,
		DB_TXN_WRITE_NOSYNC = 0x00000020,
		DB_UNREF = 0x00000080,
		DB_UPGRADE = 0x00000001,
		DB_USE_ENVIRON = 0x00000002,
		DB_USE_ENVIRON_ROOT = 0x00000008,
		DB_VERB_DEADLOCK = 0x00000001,
		DB_VERB_FILEOPS = 0x00000002,
		DB_VERB_FILEOPS_ALL = 0x00000004,
		DB_VERB_RECOVERY = 0x00000008,
		DB_VERB_REGISTER = 0x00000010,
		DB_VERB_REPLICATION = 0x00000020,
		DB_VERB_REPMGR_CONNFAIL = 0x00000040,
		DB_VERB_REPMGR_MISC = 0x00000080,
		DB_VERB_REP_ELECT = 0x00000100,
		DB_VERB_REP_LEASE = 0x00000200,
		DB_VERB_REP_MISC = 0x00000400,
		DB_VERB_REP_MSGS = 0x00000800,
		DB_VERB_REP_SYNC = 0x00001000,
		DB_VERB_WAITSFOR = 0x00002000,
		DB_VERIFY = 0x00000002,
		DB_WRITEOPEN = 0x00010000,
		DB_XA_CREATE = 0x00000800,
		DB_YIELDCPU = 0x00010000,
		// locks
		DB_LOCK_NORUN = 0,
		DB_LOCK_DEFAULT = 1,	/* Default policy. */
		DB_LOCK_EXPIRE = 2,	/* Only expire locks, no detection. */
		DB_LOCK_MAXLOCKS = 3,	/* Select locker with max locks. */
		DB_LOCK_MAXWRITE = 4,	/* Select locker with max writelocks. */
		DB_LOCK_MINLOCKS = 5,	/* Select locker with min locks. */
		DB_LOCK_MINWRITE = 6,	/* Select locker with min writelocks. */
		DB_LOCK_OLDEST = 7,	/* Select oldest locker. */
		DB_LOCK_RANDOM = 8,	/* Select random locker. */
		DB_LOCK_YOUNGEST = 9,	/* Select youngest locker. */
		// dbtype
		DB_BTREE=1,
		DB_HASH=2,
		DB_RECNO=3,
		DB_QUEUE=4,
		DB_UNKNOWN=5,
		// cursor
		DB_AFTER = 1,	/* Dbc.put */
		DB_APPEND = 2,	/* Db.put */
		DB_BEFORE = 3,	/* Dbc.put */
		DB_CONSUME = 4,	/* Db.get */
		DB_CONSUME_WAIT = 5,	/* Db.get */
		DB_CURRENT = 6,	/* Dbc.get, Dbc.put, DbLogc.get */
		DB_FIRST = 7,	/* Dbc.get, DbLogc->get */
		DB_GET_BOTH = 8,	/* Db.get, Dbc.get */
		DB_GET_BOTHC = 9,	/* Dbc.get (internal) */
		DB_GET_BOTH_RANGE = 10,	/* Db.get, Dbc.get */
		DB_GET_RECNO = 11,	/* Dbc.get */
		DB_JOIN_ITEM = 12,	/* Dbc.get; don't do primary lookup */
		DB_KEYFIRST = 13,	/* Dbc.put */
		DB_KEYLAST = 14,	/* Dbc.put */
		DB_LAST = 15,	/* Dbc.get, DbLogc->get */
		DB_NEXT = 16,	/* Dbc.get, DbLogc->get */
		DB_NEXT_DUP = 17,	/* Dbc.get */
		DB_NEXT_NODUP = 18,	/* Dbc.get */
		DB_NODUPDATA = 19,	/* Db.put, Dbc.put */
		DB_NOOVERWRITE = 20,	/* Db.put */
		DB_NOSYNC = 21,	/* Db.close */
		DB_POSITION = 22,	/* Dbc.dup */
		DB_PREV = 23,	/* Dbc.get, DbLogc->get */
		DB_PREV_DUP = 24,	/* Dbc.get */
		DB_PREV_NODUP = 25,	/* Dbc.get */
		DB_SET = 26,	/* Dbc.get, DbLogc->get */
		DB_SET_RANGE = 27,	/* Dbc.get */
		DB_SET_RECNO = 28,	/* Db.get, Dbc.get */
		DB_UPDATE_SECONDARY = 29,	/* Dbc.get, Dbc.del (internal) */
		DB_WRITECURSOR = 30,	/* Db.cursor */
		DB_WRITELOCK = 31,	/* Db.cursor (internal) */
		// errors
		DB_BUFFER_SMALL = (-30999),/* User memory too small for return. */
		DB_DONOTINDEX = (-30998),/* "Null" return from 2ndary callbk. */
		DB_FOREIGN_CONFLICT = (-30997),/* A foreign db constraint triggered. */
		DB_KEYEMPTY = (-30996),/* Key/data deleted or never created. */
		DB_KEYEXIST = (-30995),/* The key/data pair already exists. */
		DB_LOCK_DEADLOCK = (-30994),/* Deadlock. */
		DB_LOCK_NOTGRANTED = (-30993),/* Lock unavailable. */
		DB_LOG_BUFFER_FULL = (-30992),/* In-memory log buffer full. */
		DB_NOSERVER = (-30991),/* Server panic return. */
		DB_NOSERVER_HOME = (-30990),/* Bad home sent to server. */
		DB_NOSERVER_ID = (-30989),/* Bad ID sent to server. */
		DB_NOTFOUND = (-30988),/* Key/data pair not found (EOF). */
		DB_OLD_VERSION = (-30987),/* Out-of-date version. */
		DB_PAGE_NOTFOUND = (-30986),/* Requested page not found. */
		DB_REP_DUPMASTER = (-30985),/* There are two masters. */
		DB_REP_HANDLE_DEAD = (-30984),/* Rolled back a commit. */
		DB_REP_HOLDELECTION = (-30983),/* Time to hold an election. */
		DB_REP_IGNORE = (-30982),/* This msg should be ignored.*/
		DB_REP_ISPERM = (-30981),/* Cached not written perm written.*/
		DB_REP_JOIN_FAILURE = (-30980),/* Unable to join replication group. */
		DB_REP_LEASE_EXPIRED = (-30979),/* Master lease has expired. */
		DB_REP_LOCKOUT = (-30978),/* API/Replication lockout now. */
		DB_REP_NEWSITE = (-30977),/* New site entered system. */
		DB_REP_NOTPERM = (-30976),/* Permanent log record not written. */
		DB_REP_UNAVAIL = (-30975),/* Site cannot currently be reached. */
		DB_RUNRECOVERY = (-30974),/* Panic return. */
		DB_SECONDARY_BAD = (-30973),/* Secondary index corrupt. */
		DB_VERIFY_BAD = (-30972),/* Verify failed; bad format. */
		DB_VERSION_MISMATCH = (-30971),/* Environment version mismatch. */
		DB_ALREADY_ABORTED = (-30899),
		DB_DELETED = (-30898),/* Recovery file marked deleted. */
		DB_EVENT_NOT_HANDLED = (-30897),/* Forward event to application. */
		DB_NEEDSPLIT = (-30896),/* Page needs to be split. */
		DB_REP_BULKOVF = (-30895),/* Rep bulk buffer overflow. */
		DB_REP_EGENCHG = (-30894),/* Egen changed while in election. */
		DB_REP_LOGREADY = (-30893),/* Rep log ready for recovery. */
		DB_REP_NEWMASTER = (-30892),/* We have learned of a new master. */
		DB_REP_PAGEDONE = (-30891),/* This page was already done. */
		DB_SURPRISE_KID = (-30890),/* Child commit where parent didn't know it was a parent. */
		DB_SWAPBYTES = (-30889),/* Database needs byte swapping. */
		DB_TIMEOUT = (-30888),/* Timed out waiting for election. */
		DB_TXN_CKP = (-30887),/* Encountered ckp record in log. */
		DB_VERIFY_FATAL = (-30886),/* DB->verify cannot proceed. */
		// events
		DB_EVENT_NO_SUCH_EVENT = 0, /* out-of-band sentinel value */
		DB_EVENT_PANIC = 1,
		DB_EVENT_REP_CLIENT = 2,
		DB_EVENT_REP_ELECTED = 3,
		DB_EVENT_REP_MASTER = 4,
		DB_EVENT_REP_NEWMASTER = 5,
		DB_EVENT_REP_PERM_FAILED = 6,
		DB_EVENT_REP_STARTUPDONE = 7,
		DB_EVENT_WRITE_FAILED = 8,
		// obsolete, for backwards compatibility
		DB_JOINENV = 0,
	}
}
